/**
 * 
 */
package de.devisnik.eidle.flashlight;

import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;

class SpotMover implements Runnable {

	private final Control control;
	private final ISpot spot;

	public SpotMover(final Control canvas, final ISpot spot) {
		this.control = canvas;
		this.spot = spot;
	}

	public void run() {
		try {
			if (control.isDisposed()) {
				return;
			}
			final Rectangle boundingBox = spot.move(control.getBounds());
			control.redraw(boundingBox.x, boundingBox.y, boundingBox.width,
					boundingBox.height, false);
			control.getDisplay().timerExec(30, this);
		} catch (final SWTException e) {
			e.printStackTrace();
		}
	}

}